import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 666
 * Date: 2023-03-22
 * Time: 11:10
 */
public class test9 {
    public static void main(String[] args) {
        Scanner q=new Scanner(System.in);
        int n=q.nextInt();
        int[] arr=new int[n];
        for (int i = 0; i < n; i++) {
            arr[i]=q.nextInt();
        }
        int a=0;
        for (int i = 0; i < n-2; i++) {
            if(arr[i]<arr[i+1] && arr[i+1]>arr[i+2]){
                a++;
            }
            if(arr[i]>arr[i+1] && arr[i+1]<arr[i+2]){
                a++;
            }

        }
        System.out.println(a+1);
    }
}
